enable-tor: Fix breakage caused by git's fix for CVE-2022-24765
authorJoey Hess <joeyh@joeyh.name>
Mon, 26 Sep 2022 18:48:58 +0000 (14:48 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 26 Sep 2022 18:48:58 +0000 (14:48 -0400)
This relies on bfa451fc4e621700883fb3b34600bdf71f515a62 and is a bit of an
ugly hack.

Sponsored-by: Noam Kremen on Patreon
CHANGELOG
Command/EnableTor.hs

index 0a4c8f300c2afc62348587916d997571d990ffb5..7f2a6773f35cdc532ef95b5f18cd1458d9ff58a6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -38,6 +38,7 @@ git-annex (10.20220823) UNRELEASED; urgency=medium
   * Run annex.freezecontent-command and annex.thawcontent-command
     when on a crippled filesystem.
     Thanks, Reiko Asakura
+  * enable-tor: Fix breakage caused by git's fix for CVE-2022-24765.
   * Let GIT_DIR and --git-dir override git's protection against operating
     in a repository owned by another user.
 
index 0e07d1436754162664304eed9afbd71e7aab4d4c..aeae96be92b74955827d1a0646a326fc81a9890f 100644 (file)
@@ -1,6 +1,6 @@
 {- git-annex command
  -
- - Copyright 2016 Joey Hess <id@joeyh.name>
+ - Copyright 2016-2022 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -22,6 +22,8 @@ import P2P.IO
 import qualified P2P.Protocol as P2P
 import Utility.ThreadScheduler
 import RemoteDaemon.Transport.Tor
+import Git.Types
+import Config
 
 import Control.Concurrent.Async
 import qualified Network.Socket as S
@@ -70,6 +72,15 @@ start _os = do
 #endif
   where
        go userid = do
+               -- Usually git will refuse to read local configs of a git
+               -- repo belonging to another user. But in this case, the
+               -- user wants this command, run as root, to operate on
+               -- their repo. Behave as if --git-dir had been used to
+               -- specify that the git directory is intended to be used.
+               Annex.adjustGitRepo $ \r -> return $ r
+                       { gitDirSpecifiedExplicitly = True }
+               reloadConfig
+
                uuid <- getUUID
                when (uuid == NoUUID) $
                        giveup "This can only be run in a git-annex repository."